package com.rency.mtds.manager.spi.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rency.mtds.manager.spi.enums.DbType;
import com.rency.mtds.manager.spi.enums.MasterSlaveType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.rency.halo.framework.lang.enums.YesNo;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 数据源
 * @author: caiyu.ren
 * Created on 2019/9/3 10:06
 * @version: V1.0.0
 * @since JDK 11
 */
@ApiModel("数据源")
@Getter
@Setter
@ToString
public class DataSourceBO {

    @ApiModelProperty(value = "编号")
    private Long id;

    @NotEmpty(message = "应用标识不能为空")
    @Size(max = 50,message = "应用标识长度不能超过50")
    @ApiModelProperty(value = "应用标识")
    private String appId;

    @Size(max = 64,message = "应用名称长度不能超过64")
    @ApiModelProperty(value = "应用名称")
    private String appName;

    @NotEmpty(message = "数据库类型不能为空")
    @ApiModelProperty(value = "数据库类型")
    private DbType dbType;

    @NotEmpty(message = "主备类型不能为空")
    @ApiModelProperty(value = "主备类型")
    private MasterSlaveType msType;

    @NotEmpty(message = "数据库驱动类型不能为空")
    @Size(max = 100,message = "数据库驱动类型长度不能超过100")
    @ApiModelProperty(value = "数据库驱动类型",notes = "如'com.alibaba.druid.pool.DruidDataSource'")
    private String dsType;

    @NotEmpty(message = "数据库驱动不能为空")
    @Size(max = 100,message = "数据库驱动长度不能超过100")
    @ApiModelProperty(value = "数据库驱动",notes = "如'com.mysql.cj.jdbc.Driver'")
    private String dsDriver;

    @NotEmpty(message = "数据库地址不能为空")
    @Size(max = 200,message = "数据库地址长度不能超过200")
    @ApiModelProperty(value = "数据库地址")
    private String dsUrl;

    @NotEmpty(message = "数据库用户不能为空")
    @Size(max = 50,message = "数据库用户长度不能超过50")
    @ApiModelProperty(value = "数据库用户")
    private String dsUser;

    @NotEmpty(message = "数据库密码不能为空")
    @Size(max = 50,message = "数据库密码长度不能超过50")
    @ApiModelProperty(value = "数据库密码")
    private String dsPasswd;

    @Size(max = 200,message = "数据源属性长度不能超过200")
    @ApiModelProperty(value = "数据源属性")
    private String dsProperties;

    @Size(max = 100,message = "连接属性长度不能超过100")
    @ApiModelProperty(value = "连接属性")
    private String dsConnectProperties;

    @NotEmpty(message = "数据库类型不能为空")
    @ApiModelProperty(value = "是否启用")
    private YesNo enable;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtModified;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtCreate;
}
